package com.cheer.controller;

import com.cheer.common.Result;
import com.cheer.service.AuthService;
import com.cheer.service.FlowerService;
import com.cheer.service.LotteryService;
import com.cheer.vo.FlowerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author cheer
 */
@RestController
@Api(tags = "小红花")
@RequestMapping("/flower")
public class FlowerController {

    @Autowired
    private FlowerService flowerService;

    @Autowired
    private AuthService authService;

    @ApiOperation("首页 小红花 TODO")
    @GetMapping("/index")
    public Result<FlowerVO> index(HttpSession session) {
        FlowerVO flowerVO = flowerService.index(authService.getUserId(session));
        return Result.success(flowerVO);
    }


    @ApiOperation("兑换 小红花 TODO")
    @GetMapping("/exchange")
    public Result exchange(HttpSession session, Integer exchangeNum) {

        flowerService.exchange(authService.getUserId(session), exchangeNum);
        return Result.success();
    }

}
